package cn.jervain.nut.auth.core.authentication;


import cn.jervain.nut.auth.core.token.DefaultToken;
import cn.jervain.nut.auth.core.token.Token;
import lombok.Data;

import java.util.ArrayList;

@Data
public class SimpleAuthentication<T> implements Authentication<T> {

    private String username;
    private String password;
    private T detail;

    @Override
    public String getIdentity() {
        return username;
    }

    @Override
    public String getCredentials() {
        return password;
    }

    @Override
    public Token<T> transform() {
        DefaultToken<T> token = new DefaultToken<>();
        token.setId(0);
        token.setDetail(detail);
        token.setAccesses(new ArrayList<>());
        token.setRoles(new ArrayList<>());
        return token;
    }

}
